using Perfect.Marshal;
using System.Xml;

namespace editor
{
namespace cfg.map
{
[System.Serializable]
public  class SpawnBySingle : Spawn
 {

    public int totalNum ;
     public int defaultNum ;
     public int terminals ;
     


    public const int TYPE_ID = 1363469346;

    public override int GetTypeId() {
        return TYPE_ID;
    }


    public override void MarshalCompatible(Perfect.Marshal.Octets os) {
        os.WriteSize(7);
        os.WriteSize(Tag.INT | (1 << Tag.TAG_SHIFT));  os.WriteInt(objectId);  
         os.WriteSize(Tag.LIST | (2 << Tag.TAG_SHIFT));  { var _oldOs = os; os = new Perfect.Marshal.Octets(); cfg.Extensions.marshal_compatible_list_int(regionIds,os);  _oldOs.WriteOctets(os); os = _oldOs;}  
         os.WriteSize(Tag.INT | (3 << Tag.TAG_SHIFT));  os.WriteInt(group);  
         os.WriteSize(Tag.INT | (4 << Tag.TAG_SHIFT));  os.WriteInt(patrolId);  
         os.WriteSize(Tag.INT | (5 << Tag.TAG_SHIFT));  os.WriteInt(totalNum);  
         os.WriteSize(Tag.INT | (6 << Tag.TAG_SHIFT));  os.WriteInt(defaultNum);  
         os.WriteSize(Tag.INT | (7 << Tag.TAG_SHIFT));  os.WriteInt(terminals);  
         
    }

    public override void UnmarshalCompatible(Perfect.Marshal.Octets os) {
        for (int _var_num_ = os.ReadSize(); _var_num_-- > 0; ) {
            int _id_ = os.ReadSize();
            switch (_id_)
            {
            case (Tag.INT | (1 << Tag.TAG_SHIFT)):   objectId = os.ReadInt(); break;  
             case (Tag.LIST | (2 << Tag.TAG_SHIFT)):  { var _oldOs = os; os = os.ReadOctets(); regionIds = cfg.Extensions.unmarshal_compatible_list_int(os); os = _oldOs; break; }   
             case (Tag.INT | (3 << Tag.TAG_SHIFT)):   group = os.ReadInt(); break;  
             case (Tag.INT | (4 << Tag.TAG_SHIFT)):   patrolId = os.ReadInt(); break;  
             case (Tag.INT | (5 << Tag.TAG_SHIFT)):   totalNum = os.ReadInt(); break;  
             case (Tag.INT | (6 << Tag.TAG_SHIFT)):   defaultNum = os.ReadInt(); break;  
             case (Tag.INT | (7 << Tag.TAG_SHIFT)):   terminals = os.ReadInt(); break;  
             
            default: Tag.SkipUnknownField(_id_, os); break;
            }
         }
    }
    public override void MarshalXml(XmlWriter ele)
    {
        ele.WriteAttributeString("type", "SpawnBySingle");
        ele.WriteStartElement("objectId"); ele.WriteAttributeString("id", "1"); ele.WriteInt(objectId); ele.WriteEndElement();
         ele.WriteStartElement("regionIds"); ele.WriteAttributeString("id", "2"); cfg.Extensions.xml_marshal_list_int(regionIds,ele); ele.WriteEndElement();
         ele.WriteStartElement("group"); ele.WriteAttributeString("id", "3"); ele.WriteInt(group); ele.WriteEndElement();
         ele.WriteStartElement("patrolId"); ele.WriteAttributeString("id", "4"); ele.WriteInt(patrolId); ele.WriteEndElement();
         ele.WriteStartElement("totalNum"); ele.WriteAttributeString("id", "5"); ele.WriteInt(totalNum); ele.WriteEndElement();
         ele.WriteStartElement("defaultNum"); ele.WriteAttributeString("id", "6"); ele.WriteInt(defaultNum); ele.WriteEndElement();
         ele.WriteStartElement("terminals"); ele.WriteAttributeString("id", "7"); ele.WriteInt(terminals); ele.WriteEndElement();
         
    }

    public override void UnmarshalXml(XmlElement ele)
    {
        foreach (XmlElement e in ele.GetChildren())
        {
            if (int.TryParse(ele.GetAttribute("id"), out var _id_))
            {
                switch (_id_)
                {
                case 1:  objectId = ele.ReadInt(); break; 
                 case 2:  regionIds = cfg.Extensions.xml_unmarshal_list_int(ele); break; 
                 case 3:  group = ele.ReadInt(); break; 
                 case 4:  patrolId = ele.ReadInt(); break; 
                 case 5:  totalNum = ele.ReadInt(); break; 
                 case 6:  defaultNum = ele.ReadInt(); break; 
                 case 7:  terminals = ele.ReadInt(); break; 
                 
                default: break;
                }
            }
            else
            {
                switch (e.Name)
                {
                case "object_id":  objectId = ele.ReadInt(); break; 
                 case "region_ids":  regionIds = cfg.Extensions.xml_unmarshal_list_int(ele); break; 
                 case "group":  group = ele.ReadInt(); break; 
                 case "patrol_id":  patrolId = ele.ReadInt(); break; 
                 case "total_num":  totalNum = ele.ReadInt(); break; 
                 case "default_num":  defaultNum = ele.ReadInt(); break; 
                 case "terminals":  terminals = ele.ReadInt(); break; 
                 
                default: break;
                }
            }
        }
    }
}
}
}
